package com.unknown.dapp.uni.swap.log.admin.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.unknow.first.api.common.CommonPage;
import com.unknow.first.api.common.CommonParam;
import com.unknown.dapp.uni.swap.log.dto.TokenSwapQueryDTO;
import com.unknown.dapp.uni.swap.log.mapper.TTokenSwapRecord;
import com.unknown.dapp.uni.swap.log.service.ITokenSwapRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.cloud.constant.CoreConstant;
import org.cloud.dimension.annotation.SystemResource;
import org.cloud.mybatisplus.utils.MyBatisPlusUtil;
import org.cloud.vo.CommonApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "交易记录查询", tags = "交易记录查询")
@Validated
@RestController
@RequestMapping("/admin/tran")
@SystemResource(path = "/admin/tran")
public class TokenSwapAdminController {

    @Autowired
    ITokenSwapRecordService tokenSwapRecordService;

    @ApiOperation("获取Swap交易列表")
    @SystemResource(value = "/admin-getSwapTokenRecord", description = "获取Swap交易列表", authMethod = CoreConstant.AuthMethod.BYUSERPERMISSION)
    @RequestMapping(method = RequestMethod.POST, value = "/getSwapTokenRecord")
    public CommonApiResult<CommonPage<TTokenSwapRecord>> getSwapTokenRecord(CommonParam pageParam, @RequestBody TokenSwapQueryDTO queryDTO) {
        QueryWrapper<TTokenSwapRecord> queryWrapper = MyBatisPlusUtil.single().getPredicate(queryDTO);
        PageHelper.startPage(pageParam.getPage(), pageParam.getLimit(), pageParam.getSorts());
        return CommonApiResult.createSuccessResult(CommonPage.restPage(tokenSwapRecordService.list(queryWrapper)));
    }


}
